package com.hst.capacity.infra.convertor;

import com.hst.capacity.domain.model.entity.vehicle.VehicleEntity;
import com.hst.capacity.domain.model.entity.vehicle.VehicleInsuranceEntity;
import com.hst.capacity.domain.model.entity.vehicle.VehicleLicenseEntity;
import com.hst.capacity.domain.model.entity.vehicle.VehicleProfileEntity;
import com.hst.capacity.domain.model.request.vehicle.VehicleAddCertificateParam;
import com.hst.capacity.domain.model.request.vehicle.VehicleAddInsuranceParam;
import com.hst.capacity.domain.model.request.vehicle.VehicleAddParam;
import com.hst.capacity.domain.model.response.vehicle.VehicleSearchVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 *  车辆模块的POJO属性转换器
 *
 * @author jin
 * */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface VehicleConvertor {
    VehicleConvertor INSTANCE = Mappers.getMapper(VehicleConvertor.class);

    VehicleSearchVO convert(VehicleEntity vehicleEntity);

    /**
     * 车辆编辑基本信息查询转化
     * @param vehicle
     * @param vehicleP
     * @return
     */
    @Mapping(target = "idVehicle", source = "vehicle.idVehicle")
    VehicleAddParam convert(VehicleEntity vehicle, VehicleProfileEntity vehicleP);

    List<VehicleAddInsuranceParam> convert(List<VehicleInsuranceEntity> byIdVehicle);

    VehicleAddCertificateParam convert(VehicleLicenseEntity byIdVehicle);

    @Mapping(target = "registerDate",dateFormat = "yyyy-MM-dd HH:mm")
    @Mapping(target = "issueDate",dateFormat = "yyyy-MM-dd HH:mm")
    void convert(@MappingTarget VehicleProfileEntity profileEntity, VehicleAddParam param);

    void convert(@MappingTarget VehicleEntity vehicleEntity, VehicleAddParam param);
}
